const createServices = function ({ table, projectName, method = ["List", "ListByQuery", "Add", "Edit", "Del"] }) {
  return `import request from '@/utils/request';
${method.map(item => `export async function ${projectName}${item}(params) {
  return request('/api/${projectName}/${projectName}${item}', {
      method: 'post',
      data: params,
  })
}
`).join(`\n`)}
${table.filter(item => item.fk).map(item => `export async function ${item.fk.tableName}List(params) {
  return request('/api/${projectName}/${item.fk.tableName}List', {
      method: 'post',
      data: params,
  })
}
`).join(`\n`)}
${table.filter(item => item.stringType == "img").length > 0 ?`
export async function uploadFile(formData) {
  return request('/api/${projectName}/uploadFile', {
    method: 'post',
    data: formData,
  })
}
`:""}  
`
}

module.exports = createServices;